package com.wanmait.baohan.task;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * TODO
 *
 * @author 打豆豆
 * @version 1.0
 * @date 2020/11/23 16:33
 * @description:
 */
@Component
public class BaoHanTask {
    @Resource
    private HttpServletRequest request;

    /**
     * 定时器任务
     *  每天零点将出差申请编号归零
     */
    @Scheduled(cron = "0 0 0 1/1 * ? ")
    public void run(){
        System.out.println("执行定时器" + new Date());
        request.getServletContext().setAttribute("travelApplicationNumbering", 1);
        request.getServletContext().setAttribute("carApplicationNumbering", 1);
        request.getServletContext().setAttribute("ticketApplicationNumbering", 1);
        request.getServletContext().setAttribute("hotelApplicationNumbering", 1);
    }
}
